HAL TIM I/O operation function migration

HAL TIM Encoder Functions

Mode

HAL1

HAL2

Blocking Mode

  • In HAL1, to start the TIM encoder in blocking mode, you need to call:

    • HAL_TIM_Encoder_Start

  • To stop, you need to call:

    • HAL_TIM_Encoder_Stop

  • In HAL2, to start in blocking mode, you need to call:

    • HAL_TIM_IC_StartChannel

    • HAL_TIM_Start

  • To stop in blocking mode, you need to call:

    • HAL_TIM_IC_StopChannel

    • HAL_TIM_Stop

Interrupt Mode

  • In HAL1, to start the TIM encoder in interrupt mode, you need to call:

    • HAL_TIM_Encoder_Start_IT

  • To stop in interrupt mode, you need to call:

    • HAL_TIM_Encoder_Stop_IT

  • In HAL2, to start in interrupt mode, you need to call:

    • HAL_TIM_IC_StartChannel_IT

    • HAL_TIM_Start

  • To stop in interrupt mode, you need to call:

    • HAL_TIM_IC_StopChannel_IT

    • HAL_TIM_Stop

DMA Mode

  • In HAL1, to start the TIM encoder in DMA mode, you need to call:

    • HAL_TIM_Encoder_Start_DMA

  • To stop in DMA mode, you need to call:

    • HAL_TIM_Encoder_Stop_DMA

  • In HAL2, to start in DMA mode, you need to call:

    • HAL_TIM_IC_StartChannel_DMA

    • HAL_TIM_Start

  • To stop in DMA mode, you need to call:

    • HAL_TIM_IC_StopChannel_DMA

    • HAL_TIM_Stop

    Note

    In encoder mode 3, you must call the function HAL_TIM_IC_StartChannel/IT/DMA twice for channel 1 and 2


HAL TIM OC/OCN & PWM/PWMN Functions

HAL1

HAL2

Blocking Mode

  • In HAL1, the blocking mode for various timer functionalities is managed using specific functions:

    • Timer Output Compare (OC):

      • To start: HAL_TIM_OC_Start

      • To stop: HAL_TIM_OC_Stop

    • Timer Pulse Width Modulation (PWM):

      • To start: HAL_TIM_PWM_Start

      • To stop: HAL_TIM_PWM_Stop

    • Timer Output Compare N (OCN):

      • To start: HAL_TIMEx_OCN_Start

      • To stop: HAL_TIMEx_OCN_Stop

    • Timer PWM N (PWMN):

      • To start: HAL_TIMEx_PWMN_Start

      • To stop: HAL_TIMEx_PWMN_Stop

  • In HAL2, all modes are handled by the following sequence:

    • To start:

      • HAL_TIM_OC_StartChannel

      • HAL_TIM_Start

    • To stop:

      • HAL_TIM_OC_StopChannel

      • HAL_TIM_Stop

Interrupt Mode

  • In HAL1, the interrupt mode is managed using specific functions:

    • Timer Output Compare (OC):

      • To start: HAL_TIM_OC_Start_IT

      • To stop: HAL_TIM_OC_Stop_IT

    • Timer Pulse Width Modulation (PWM):

      • To start: HAL_TIM_PWM_Start_IT

      • To stop: HAL_TIM_PWM_Stop_IT

    • Timer Output Compare N (OCN):

      • To start: HAL_TIMEx_OCN_Start_IT)

      • To stop: HAL_TIMEx_OCN_Stop_IT

    • Timer PWM N (PWMN):

      • To start: HAL_TIMEx_PWMN_Start_IT

      • To stop: HAL_TIMEx_PWMN_Stop_IT

  • In HAL2, all modes are handled by the following sequence:

    • To start:

      • HAL_TIM_OC_StartChannel_IT

      • HAL_TIM_Start

    • To stop:

      • HAL_TIM_OC_StopChannel_IT

      • HAL_TIM_Stop

DMA Mode

  • In HAL1, the DMA mode for various timer functionalities is managed using specific functions:

    • Timer Output Compare (OC):

      • To start: HAL_TIM_OC_Start_DMA

      • To stop: HAL_TIM_OC_Stop_DMA

    • Timer Pulse Width Modulation (PWM):

      • To start: HAL_TIM_PWM_Start_DMA

      • To stop: HAL_TIM_PWM_Stop_DMA

    • Timer Output Compare N (OCN):

      • To start: HAL_TIMEx_OCN_Start_DMA

      • To stop: HAL_TIMEx_OCN_Stop_DMA

    • Timer PWM N (PWMN):

      • To start: HAL_TIMEx_PWMN_Start_DMA

      • To stop: HAL_TIMEx_PWMN_Stop_DMA

  • In HAL2, all modes are handled by the following sequence:

    • To start:

      • HAL_TIM_OC_StartChannel_DMA

      • HAL_TIM_Start

    • To stop:

      • HAL_TIM_OC_StopChannel_DMA

      • HAL_TIM_Stop


HAL TIM Input Capture (IC) Functions

HAL1

HAL2

Blocking Mode

  • In HAL1, the input capture in blocking mode is managed using the following functions:

    • To start: HAL_TIM_IC_Start

    • To stop: HAL_TIM_IC_Stop

  • In HAL2, the blocking mode is handled by:

    • To start:

      • HAL_TIM_IC_StartChannel

      • HAL_TIM_Start

    • To stop:

      • HAL_TIM_IC_StopChannel

      • HAL_TIM_Stop

Interrupt Mode

  • In HAL1, the input capture in interrupt mode is managed using the following functions:

    • To start: HAL_TIM_IC_Start_IT

    • To stop: HAL_TIM_IC_Stop_IT

  • In HAL2, the interrupt mode is handled by:

    • To start:

      • HAL_TIM_IC_StartChannel_IT

      • HAL_TIM_Start

    • To stop:

      • HAL_TIM_IC_StopChannel_IT

      • HAL_TIM_Stop

DMA Mode

  • In HAL1, the input capture in DMA mode is managed using the following functions:

    • To start: HAL_TIM_IC_Start_DMA

    • To stop: HAL_TIM_IC_Stop_DMA

  • In HAL2, the DMA mode is handled by:

    • To start:

      • HAL_TIM_IC_Start_DMA

      • HAL_TIM_Start

    • To stop:

      • HAL_TIM_IC_StopChannel_DMA

      • HAL_TIM_Stop


HAL TIM Hall Sensor Functions

HAL1

HAL2

Blocking Mode

  • In HAL1, the Hall Sensor in blocking mode is managed using the following functions:

    • To start: HAL_TIMEx_HallSensor_Start

    • To stop: HAL_TIMEx_HallSensor_Stop

  • In HAL2, the blocking mode is handled by:

    • To start:

      • HAL_TIM_IC_StartChannel

      • HAL_TIM_Start

    • To stop:

      • HAL_TIM_IC_StopChannel

      • HAL_TIM_Stop

Interrupt Mode

  • In HAL1, the Hall Sensor in interrupt mode is managed using the following functions:

    • To start: HAL_TIMEx_HallSensor_Start_IT

    • To stop: HAL_TIMEx_HallSensor_Stop_IT

  • In HAL2, the interrupt mode is handled by:

    • To start:

      • HAL_TIM_IC_StartChannel_IT

      • HAL_TIM_Start

    • To stop:

      • HAL_TIM_IC_StopChannel_IT

      • HAL_TIM_Stop

DMA Mode

  • In HAL1, the Hall Sensor in DMA mode is managed using the following functions:

    • To start: HAL_TIMEx_HallSensor_Start_DMA

    • To stop: HAL_TIMEx_HallSensor_Stop_DMA

  • In HAL2, the DMA mode is handled by:

    • To start:

      • HAL_TIM_IC_Start_DMA

      • HAL_TIM_Start

    • To stop:

      • HAL_TIM_IC_StopChannel_DMA

      • HAL_TIM_Stop

Note

In the Hall Sensor Interface the three possible channels that can be used are TIM_CHANNEL_1, TIM_CHANNEL_2 and TIM_CHANNEL_3


HAL TIM DMA Burst Functions

HAL1

HAL2

DMA Burst Write & read operation

In HAL1

  • DMA Burst Write is managed using the following functions:

    • To start: HAL_TIM_DMABurst_WriteStart

    • To start multi-write: HAL_TIM_DMABurst_MultiWriteStart

    • To stop: HAL_TIM_DMABurst_WriteStop

  • DMA Burst Read is managed using the following functions:

    • To start: HAL_TIM_DMABurst_ReadStart

    • To start multi-read: HAL_TIM_DMABurst_MultiReadStart

    • To stop: HAL_TIM_DMABurst_ReadStop

  • In HAL2, DMA Burst operations are handled by:

    • To set configuration: HAL_TIM_SetConfigDMABurst

    • To start (read or write based on direction):

    • HAL_TIM_StartDMABurst

    • To stop: HAL_TIM_StopDMABurst


HAL TIM One Pulse Start/Stop functions

HAL1

HAL2

Blocking mode

  • In HAL1 to start the TIM one pulse in blocking mode you need to call:

    • HAL_TIM_OnePulse_Start

    • HAL_TIMEx_OnePulseN_Start.

  • To stop in blocking mode, you need to call:

    • HAL_TIM_OnePulse_Stop

    • HAL_TIMEx_OnePulseN_Stop.

  • In HAL2 just replace by the following sequence to start in blocking mode:

    • HAL_TIM_OC_StartChannel to start the output channel

    • HAL_TIM_IC_StartChannel to start the input channel

    • HAL_TIM_Start

  • To stop in blocking mode, you need to call:

    • HAL_TIM_OC_StopChannel

    • HAL_TIM_IC_StopChannel

    • HAL_TIM_Stop

Interrupt mode

  • In HAL1 to start the TIM one pulse in interrupt mode you need to call:

    • HAL_TIM_OnePulse_Start_IT

    • HAL_TIMEx_OnePulseN_Start_IT

  • To stop in interrupt mode, you need to call:

    • HAL_TIM_OnePulse_Stop_IT

    • HAL_TIMEx_OnePulse_Stop_IT.

  • In HAL2 just replace by the following sequence to start in interrupt mode:

    • HAL_TIM_OC_StartChannel_IT to start the output channel in interrupt mode

    • HAL_TIM_IC_StartChannel to start the input channel

    • HAL_TIM_Start

  • To stop in interrupt mode, you need to call:

    • HAL_TIM_OC_StopChannel_IT

    • HAL_TIM_IC_StopChannel

    • HAL_TIM_Stop


HAL TIM base stop interrupt

HAL1

HAL2

HAL_TIM_Base_Stop_IT()
HAL_TIM_Stop_IT()

HAL TIM base stop DMA

HAL1

HAL2

HAL_TIM_Base_Stop_DMA()
HAL_TIM_Stop_DMA()

HAL TIM base stop

HAL1

HAL2

HAL_TIM_Base_Stop()
HAL_TIM_Stop()

HAL TIM base start interrupt

HAL1

HAL2

HAL_TIM_Base_Start_IT()
HAL_TIM_Start_IT()

HAL TIM base stop DMA

HAL1

HAL2

HAL_TIM_Base_Start_DMA()
HAL_TIM_Start_DMA()

HAL TIM base start

HAL1

HAL2

HAL_TIM_Base_Start()
HAL_TIM_Start()